package com.stefan.consumer;


import com.stefan.framework.Invocation;
import com.stefan.framework.ProxyFactory;
import com.stefan.framework.protocol.http.HttpClient;
import com.stefan.provider.api.HelloService;

public class App {
    public static void main(String[] args) throws Exception {
        //调用HelloService服务
//        HttpClient httpClient = new HttpClient();
//        Invocation invocation = new Invocation("com.stefan.provider.api.HelloService",
//                "sayHello", new Class[]{String.class}, new Object[]{"Stefan"});
//        String result = httpClient.send("localhost", 8080, invocation);
//        System.out.println(result);
        // 上面的写法可以放入一个方法中，一般 service都是接口，这里需要使用动态代理
        HelloService helloService = ProxyFactory.createProxy(HelloService.class);
        String s = helloService.sayHello("stefan");
        System.out.println(s);
    }
}
